package chapter06;
import java.util.*;
public class Test01_arraylist {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        //增加元素
        list.add("张三");
        list.add("李四");
        list.add(20);
        list.add(new Person("李四",20));
        //直接输入
        System.out.println(list);
        //获得array大小
        System.out.println(list.size());
        //得到对应下标的元素
        Person p = (Person)list.get(3);
        p.info();
        //删除
        list.remove(0);
        //更改
        list.set(0,"王五");
        System.out.println(list);
    }
}
class Person{
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void info(){
        System.out.println(name);
        System.out.println(age);
    }
}

